/*
 * Projet industriel VAMP 2012 
 */
package com.vampmobile.android.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.vampmobile.R;
import com.vampmobile.android.VampCommon.Commons.KINDS;

/**
 * class to display home NFC Control FO && AM
 */
public class VampNFC extends Activity {

	public static final String TAG = "VampNFC";

	private ImageView mHomeTitle;
	private ImageView mHomeButton;
	private ImageView mBackButton;
	private ImageView mSearchButton;
	private ImageView mQuitButton;
	private ImageView mAccountButton;

	/*
	 * method used by clicking on the list of item
	 */
	class ItemClickListener implements OnClickListener {

		private String name = null;
		private Long id = null;
		private KINDS kind = null;

		public ItemClickListener(KINDS kind) {
			super();
			this.kind = kind;
		}

		// case video and music
		public ItemClickListener(KINDS kind, Long id, String name) {
			super();
			this.kind = kind;
			this.id = id;
			this.name = name;
		}

		public void onClick(View mView) {
			switch (kind) {
			case TOOLBAR:
				FrameLayout toolbar = (FrameLayout) findViewById(R.id.toolbar); 
				if (toolbar.getVisibility()!=View.VISIBLE)
					toolbar.setVisibility(View.VISIBLE);
				else
					toolbar.setVisibility(View.GONE);
				break;
			case QUIT:
				android.os.Process.killProcess(android.os.Process.myPid());
				java.lang.System.exit(0);
				finish();
				break;
			case SEARCH:
				break;
			case BACK:
				goHome();
				break;
			case PROFILE_TITLE:
				Intent myIntent = new Intent();
				myIntent.setClass(getApplicationContext(), Profile.class);
				myIntent.setAction(Intent.ACTION_VIEW);
				finish();
				startActivity(myIntent);
				break;
			case HOME_TITLE:
				Intent i = new Intent();
				i.setClass(getApplicationContext(), Home.class);
				i.setAction(Intent.ACTION_VIEW);
				finish();
				startActivity(i);
				break;
			}

		}
	}

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setTitle(TAG);
		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.vampnfc);
		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);
		((TextView) findViewById(R.id.activityTitle)).setText("Vehicul Control");

		// button of title bar
		mHomeTitle = (ImageView) findViewById(R.id.home_title);
		mHomeTitle.setOnClickListener(new ItemClickListener(KINDS.TOOLBAR));
		// button of toolbar
		mHomeButton = (ImageView) findViewById(R.id.home);
		mHomeButton.setOnClickListener(new ItemClickListener(KINDS.HOME_TITLE));
		mBackButton = (ImageView) findViewById(R.id.back_button);
		mBackButton.setOnClickListener(new ItemClickListener(KINDS.BACK));
		mSearchButton = (ImageView) findViewById(R.id.search);
		mSearchButton.setOnClickListener(new ItemClickListener(KINDS.SEARCH));
		mQuitButton = (ImageView) findViewById(R.id.quit);
		mQuitButton.setOnClickListener(new ItemClickListener(KINDS.QUIT));
		mAccountButton = (ImageView) findViewById(R.id.account);
		mAccountButton.setOnClickListener(new ItemClickListener(KINDS.PROFILE_TITLE));		
	}
	public void goHome() {
		Intent i = new Intent();
		i.setClass(getApplicationContext(), Home.class);
		i.setAction(Intent.ACTION_VIEW);
		finish();
		startActivity(i);
	}



}
